#!/bin/sh
# Dont ultrapass header "|"

#-------HEADER---------------------------------------------------------------------|
#AUTOR:
# Jefferson Rocha <lrcjefferson@gmail.com>
#
#DESCRIPTION:
# Trash, CLI terminal
#
#CHANGELOG
# (V1.2) 20/03/2018 - Jefferson Rocha
#   -Now if you run as root it does not show any more errors!
#----------------------------------------------------------------------------------|

_trash(){
#-----Variables
local dir_trash="${HOME}/.local/share/Trash/files/"
local archive_temp="/tmp/random.trash"

#-----Functions
size_archives(){
    cd ${dir_trash} 2>/dev/null && du -hs > ${archive_temp}
   if [ -e "/tmp/random.trash" ]; then
     echo -e "\033[34;1mSizes:\033[m
     $(cat /tmp/random.trash)
----------------------------------"
   fi
rm "${archive_temp}" 2>/dev/null
}

# now, start here :)
size_archives # call function

# directory exist?, bye bye.
if [ -d ${dir_trash} ]; then
  cd ${dir_trash} && rm -rv * 2>/dev/null
  echo -e "\033[31;1msucessfull.\033[m"
else
  echo "Directory '${dir_trash}' not found in system!"
fi
}
